package com.designPatterns.observer;

import java.util.ArrayList;
import java.util.List;

public class ConcreteSubject implements Subject {
	private List<Observer> list=new ArrayList<Observer>();
	private double hight;
	private double temperature;
	private double humidity;
	
	public double getHight() {
		return hight;
	}

	public void setHight(double hight) {
		this.hight = hight;
	}

	public double getTemperature() {
		return temperature;
	}

	public void setTemperature(double temperature) {
		this.temperature = temperature;
	}

	public double getHumidity() {
		return humidity;
	}

	public void setHumidity(double humidity) {
		this.humidity = humidity;
	}

	@Override
	public void registerObserver(Observer observer) {
		list.add(observer);
	}

	@Override
	public void remove(Observer observer) {
		if(list.contains(observer)){
			list.remove(observer);
		}
	}
	
	@Override
	public void update() {
		for (Observer observer : list) {
			observer.update(this.getTemperature(),this.getHight(),this.getHumidity());
		}
	}
	
}
